<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<title>导入门店</title>
	<link rel="stylesheet" href="/layui/css/layui.css">
	<link rel="stylesheet" href="/css/HyqPublic.css">
	<style type="text/css">
		body{
			background: #e9e9e9; 
			margin: 0;
			color: rgba(0,0,0,.65);
			font-size: 14px;
		}
		/*公共头部带搜索*/
		.public_container{
			margin: 20px;
			background: #fff;
		}
		.public_title_active{
			color: #1E9FFF;
			border-bottom: 1px solid #1E9FFF;
		}
		.public_title_container{
			height: 54px;
			padding: 0 20px;
			font-size: 14px;
			display: flex;
			align-items: center;
			background: #f9f9f9;
			border-bottom: 1px solid #f0f0f0;
		}
		.public_title_container a{
			margin-right: 30px;
			height: 54px;
			line-height: 54px;
			cursor: pointer;
		}
		.select_img{
			height: 40px;
		}
		/*公共表单部分*/
		.public_form_container{
			padding: 20px 20px 40px 20px;
		}
		.public_form_content{
			padding: 24px 40px 24px 0;
			background: #fff;
			margin-bottom: 8px;
		}
		.layui-form-label{
			width: 105px;
		}
	.layui-input-block{
		margin-left: 135px !important;
	}
	</style>
</head>
<body>
	<div class="public_container">
		<div class="public_content">
			<div class="public_title_container">
				<a href="index.html">点餐码列表</a>
				<a href="add_bg.html"  class="public_title_active">配置</a>
			</div>
		</div>
		<div class="public_form_container">
			<div class="public_form_content">
				<div class="layui-form-item">
		            <label class="layui-form-label">按钮文字：</label>
		            <div class="layui-input-block">
		                <input type="text" id="text" placeholder="请输入按钮文字信息" autocomplete="off" class="layui-input" value="{$bg->text}">
		            </div>
		        </div>
		        <div class="layui-form-item">
		            <label class="layui-form-label">添加好友文案：</label>
		            <div class="layui-input-block">
		                <input type="text" id="add_text" name="add_text" placeholder="请输入添加好友文案" autocomplete="off" class="layui-input" value="{$bg->add_text}">
		            </div>
		        </div>
		        <div class="layui-form-item">
		            <label class="layui-form-label">背景图片：</label>
		            <div class="layui-input-block">
		                <div class="layui-upload">
		                   	<div style="margin: 20px 0 10px;">
			         			<input type="hidden" name="poster_imgurl" value="{$bg->background}" id="posterimg" />
			         			<img src="{$bg->background}" alt="" id="background" style="width: 100px;">
			                  	<button type="button" data-target="posterimg" class="layui-btn layui-btn-sm layui-btn-normal select_img">
			                    	<i class="layui-icon">&#xe654;</i>上传背景图片
			                  	</button>
		                	</div>
		                </div>
		            </div>
		        </div> 
		    	<div class="layui-input-block">
			      	<button class="layui-btn layui-btn-normal" onclick="add_bg()">确定</button>
			    </div>
    		</div> 
    	</div> 
	</div>	
	<script src="/cdn/jquery.min.js"></script>
	<script src="/layui/layui.all.js"></script>
	<script src="/js/ajax.js"></script>
	<script type="text/javascript">
	function add_bg(id){
		var background = $("#posterimg").val();
		var text = $("#text").val();
		var add_text = $("#add_text").val();
		myAjaxPost(false, true, '', { add_text:add_text,background:background,text:text}, function (resp) {
			layer.msg(resp.msg);
		})
	}
	$('.select_img').on('click',function  () {
	  	var targetId=this.getAttribute('data-target');
	  	layer.open({
			title:'图片库',
			type: 2,
			area: ['700px', '450px'],
			fixed: false, //不固定
			maxmin: false,
			content: '/imgLib/lib.html?type=vshop_img&target='+targetId
	  	});
	})

	window.uploadImgCallback=function (tgt,url) {
	  console.log('选择图片结果',tgt,url);
	  if(tgt=='posterimg'){
		var inputEle=$('#posterimg');
		var prevEle=$('#background');
		inputEle.val(url);
		prevEle.attr('src',url);
		prevEle.show();
	  }
	};
	</script>
</body>
</html>